// 分页查询
function serch_bean(pageNum){
    //form表单序列化
    var all_val = $("#asdasd").serializeArray();
    var pageN = pageNum;
    $.get("/myspringboot/selectSupervisoryBodyAll",{map:all_val,pageNum:pageN},function(pageInfo){
        var aaaa = "";  //将后端返回的参数转化为一个字符串
        $("#checkOne").empty();
        var result = pageInfo.data.list;
        yibu(pageInfo.data.pages,pageInfo.data.pageNum);
        for (var i = 0; i < result.length; i++) {    //循环遍历
            aaaa += "<tr><td>"+result[i].sbId+"</td><td>" + result[i].sbName + "</td><td>" + result[i].sbAdress +"</td>" +
                "<td>" + result[i].sbPhone + "</td><td>" + result[i].sbContacts + "</td><td>" + result[i].sbFax +"</td>" +
                "<td>" + result[i].sbEmail+ "</td><td>" + result[i].sbUrl+ "</td>"+
                "<td id='"+ result+"'><button  data-toggle=\"modal\" data-target=\"#myModal\">新增</button> " +
                "|<button  data-toggle=\"modal\" data-target=\"#myModal1\" onclick='xiugai1("+result[i].sbId+")'>修改</button>" +
                "|<a  href='/myspringboot/deleteSupervisoryBody?sbId=" +result[i].sbId+"'>删除</a></td></tr>";
            $("#checkOne").append(aaaa);
            aaaa = "";
        }
    })
}
//多条件查询
function serch_bean1(){
    //form表单序列化
    var all_val = $("#asdasd").serializeArray();

    $.get("/myspringboot/selectSupervisoryBody",all_val,function(result){
        var aaaa = "";  //将后端返回的参数转化为一个字符串
        $("#checkOne").empty();
        for (var i = 0; i < result.length; i++) {    //循环遍历
            aaaa += "<tr><td>"+result[i].sbId+"</td>" + "<td>" + result[i].sbName + "</td><td>" + result[i].sbAdress +"</td>" +
                "<td>" + result[i].sbPhone + "</td><td>" + result[i].sbContacts + "</td><td>" + result[i].sbFax +"</td>" +
                "<td>" + result[i].sbEmail+ "</td><td>" + result[i].sbUrl+ "</td>"+
                "<td id='"+ result+"'><button  data-toggle=\"modal\" data-target=\"#myModal\">新增</button> " +
                "|<button  data-toggle=\"modal\" data-target=\"#myModal1\" onclick='xiugai1("+result[i].sbId+")'>修改</button>" +
                "|<a  href='/myspringboot/deleteSupervisoryBody?sbId=" +result[i].sbId+"'>删除</a></td></tr>";
            $("#checkOne").append(aaaa);
            aaaa = "";
        }
    })
}

//添加检察机构
function lasupervisorybody() {
    var v = $("#search_form").serializeArray();
    $.ajax({
        url:"/myspringboot/insertSupervisoryBody",
        data:v,
        type:"post",
        dataType:"json",
        success :function (result) {
            if(result=="SUCCESS"){
                alert("成功");
                aa();
                //location.replace(location.href)
            }else{
                alert("删除失败")
            }
        }
    })
}

//修改
function xiugai1(supId) {
    //通过截取路径的字符串 来获取到参数
    $.getJSON("/myspringboot/selectsbById", {supId:supId}, function (result12) {
        $("#sbId").val(supId);
        $("#name").val(result12.sbName);
        $("#address").val(result12.sbAdress);
        $("#phone").val(result12.sbPhone);
        $("#contacts").val(result12.sbContacts);
        $("#fax").val(result12.sbFax);
        $("#email").val(result12.sbEmail);
        $("#url").val(result12.sbUrl);
        //把id隐藏一下
    });
}
//修改方法
function xiugai2(sbId){
    var v = $("#xiugai").serializeArray();
    $.ajax({
        url:"/myspringboot/updateSupervisoryBody",
        data:v,
        type:"post",
        dataType:"json",
        success :function (result) {
            // if(result=="SUCCESS"){
            //     alert("成功");
            //     aa();
            //     //location.replace(location.href)
            // }else{
            //     alert("修改失败")
            // }
        }
    })
}